<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: Color conversions</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Color conversions </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>See <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#ga397ae87e1288a81d2363b61574eb8cab" title="Converts an image from one color space to another. ">cv::cvtColor</a> and <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#ga4e0972be5de079fed4e3a10e24ef5ef0">cv::ColorConversionCodes</a> </p><dl class="todo"><dt><b><a class="el" href="../../dd/da0/todo.html#_todo000014">Todo:</a></b></dt><dd>document other conversion modes</dd></dl>
<p><a class="anchor" id="color_convert_rgb_gray"></a></p><h2>RGB \(\leftrightarrow\) GRAY </h2>
<p>Transformations within RGB space like adding/removing the alpha channel, reversing the channel order, conversion to/from 16-bit RGB color (R5:G6:B5 or R5:G5:B5), as well as conversion to/from grayscale using: </p><p class="formulaDsp">
\[\text{RGB[A] to Gray:} \quad Y \leftarrow 0.299 \cdot R + 0.587 \cdot G + 0.114 \cdot B\]
</p>
<p> and </p><p class="formulaDsp">
\[\text{Gray to RGB[A]:} \quad R \leftarrow Y, G \leftarrow Y, B \leftarrow Y, A \leftarrow \max (ChannelRange)\]
</p>
<p> The conversion from a RGB image to gray is done with: </p><div class="fragment"><div class="line">cvtColor(src, bwsrc, cv::COLOR_RGB2GRAY);</div></div><!-- fragment --><p> More advanced channel reordering can also be done with <a class="el" href="../../d2/de8/group__core__array.html#ga51d768c270a1cdd3497255017c4504be" title="Copies specified channels from input arrays to the specified channels of output arrays. ">cv::mixChannels</a>. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a353a4b8db9040165db4dacb5bcefb6ea" title="convert between RGB/BGR and grayscale, color conversions ">cv::COLOR_BGR2GRAY</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0ae50d0c66ee53e974234ac84cf51d1d4e">cv::COLOR_RGB2GRAY</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a869da65c045477f2f17d39395df65b2d">cv::COLOR_GRAY2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a164663625b9c473f69dd47cdd7a31acc">cv::COLOR_GRAY2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_xyz"></a></p><h2>RGB \(\leftrightarrow\) CIE XYZ.Rec 709 with D65 white point </h2>
<p class="formulaDsp">
\[\begin{bmatrix} X \\ Y \\ Z \end{bmatrix} \leftarrow \begin{bmatrix} 0.412453 &amp; 0.357580 &amp; 0.180423 \\ 0.212671 &amp; 0.715160 &amp; 0.072169 \\ 0.019334 &amp; 0.119193 &amp; 0.950227 \end{bmatrix} \cdot \begin{bmatrix} R \\ G \\ B \end{bmatrix}\]
</p>
 <p class="formulaDsp">
\[\begin{bmatrix} R \\ G \\ B \end{bmatrix} \leftarrow \begin{bmatrix} 3.240479 &amp; -1.53715 &amp; -0.498535 \\ -0.969256 &amp; 1.875991 &amp; 0.041556 \\ 0.055648 &amp; -0.204043 &amp; 1.057311 \end{bmatrix} \cdot \begin{bmatrix} X \\ Y \\ Z \end{bmatrix}\]
</p>
<p> \(X\), \(Y\) and \(Z\) cover the whole value range (in case of floating-point images, \(Z\) may exceed 1).</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0ab3b3aba03d2e2a92fbd7564efd47e38b" title="convert RGB/BGR to CIE XYZ, color conversions ">cv::COLOR_BGR2XYZ</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0af3894ec8b239815e8a9075099805991a">cv::COLOR_RGB2XYZ</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0aa4d7480cfca520a55ae13ff0c5268796">cv::COLOR_XYZ2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a95815945a63cc47ce9237654857f231e">cv::COLOR_XYZ2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_ycrcb"></a></p><h2>RGB \(\leftrightarrow\) YCrCb JPEG (or YCC) </h2>
<p class="formulaDsp">
\[Y \leftarrow 0.299 \cdot R + 0.587 \cdot G + 0.114 \cdot B\]
</p>
 <p class="formulaDsp">
\[Cr \leftarrow (R-Y) \cdot 0.713 + delta\]
</p>
 <p class="formulaDsp">
\[Cb \leftarrow (B-Y) \cdot 0.564 + delta\]
</p>
 <p class="formulaDsp">
\[R \leftarrow Y + 1.403 \cdot (Cr - delta)\]
</p>
 <p class="formulaDsp">
\[G \leftarrow Y - 0.714 \cdot (Cr - delta) - 0.344 \cdot (Cb - delta)\]
</p>
 <p class="formulaDsp">
\[B \leftarrow Y + 1.773 \cdot (Cb - delta)\]
</p>
<p> where </p><p class="formulaDsp">
\[delta = \left \{ \begin{array}{l l} 128 &amp; \mbox{for 8-bit images} \\ 32768 &amp; \mbox{for 16-bit images} \\ 0.5 &amp; \mbox{for floating-point images} \end{array} \right .\]
</p>
<p> Y, Cr, and Cb cover the whole value range. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a63f063ef276a066c4e122997cfd55d6e" title="convert RGB/BGR to luma-chroma (aka YCC), color conversions ">cv::COLOR_BGR2YCrCb</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a56022734d5961924a9e556879f6f05a2">cv::COLOR_RGB2YCrCb</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0aa6d4108b0f3d5e21dc246a0c59592b38">cv::COLOR_YCrCb2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a27b56972a73ad4f2660512ac1cca552d">cv::COLOR_YCrCb2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_hsv"></a></p><h2>RGB \(\leftrightarrow\) HSV </h2>
<p>In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.</p>
<p class="formulaDsp">
\[V \leftarrow max(R,G,B)\]
</p>
 <p class="formulaDsp">
\[S \leftarrow \fork{\frac{V-min(R,G,B)}{V}}{if \(V \neq 0\)}{0}{otherwise}\]
</p>
 <p class="formulaDsp">
\[H \leftarrow \forkfour{{60(G - B)}/{(V-min(R,G,B))}}{if \(V=R\)} {{120+60(B - R)}/{(V-min(R,G,B))}}{if \(V=G\)} {{240+60(R - G)}/{(V-min(R,G,B))}}{if \(V=B\)} {0}{if \(R=G=B\)}\]
</p>
<p> If \(H&lt;0\) then \(H \leftarrow H+360\) . On output \(0 \leq V \leq 1\), \(0 \leq S \leq 1\), \(0 \leq H \leq 360\) .</p>
<p>The values are then converted to the destination data type:</p><ul>
<li>8-bit images: \(V \leftarrow 255 V, S \leftarrow 255 S, H \leftarrow H/2 \text{(to fit to 0 to 255)}\)</li>
<li>16-bit images: (currently not supported) \(V &lt;- 65535 V, S &lt;- 65535 S, H &lt;- H\)</li>
<li>32-bit images: H, S, and V are left as is</li>
</ul>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0aa4a7f0ecf2e94150699e48c79139ee12" title="convert RGB/BGR to HSV (hue saturation value) with H range 0..180 if 8 bit image, color conversions ...">cv::COLOR_BGR2HSV</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0aa4f6bc658bc546e1660fcab6bf7858f4">cv::COLOR_RGB2HSV</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a2a4b11ff7d29c342b66b85962a7969cd" title="backward conversions HSV to RGB/BGR with H range 0..180 if 8 bit image ">cv::COLOR_HSV2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a348965e2c1baf8e2c78c9afc17ac3de2">cv::COLOR_HSV2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_hls"></a></p><h2>RGB \(\leftrightarrow\) HLS </h2>
<p>In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.</p>
<p class="formulaDsp">
\[V_{max} \leftarrow {max}(R,G,B)\]
</p>
 <p class="formulaDsp">
\[V_{min} \leftarrow {min}(R,G,B)\]
</p>
 <p class="formulaDsp">
\[L \leftarrow \frac{V_{max} + V_{min}}{2}\]
</p>
 <p class="formulaDsp">
\[S \leftarrow \fork { \frac{V_{max} - V_{min}}{V_{max} + V_{min}} }{if \(L &lt; 0.5\) } { \frac{V_{max} - V_{min}}{2 - (V_{max} + V_{min})} }{if \(L \ge 0.5\) }\]
</p>
 <p class="formulaDsp">
\[H \leftarrow \forkfour {{60(G - B)}/{(V_{max}-V_{min})}}{if \(V_{max}=R\) } {{120+60(B - R)}/{(V_{max}-V_{min})}}{if \(V_{max}=G\) } {{240+60(R - G)}/{(V_{max}-V_{min})}}{if \(V_{max}=B\) } {0}{if \(R=G=B\) }\]
</p>
<p> If \(H&lt;0\) then \(H \leftarrow H+360\) . On output \(0 \leq L \leq 1\), \(0 \leq S \leq 1\), \(0 \leq H \leq 360\) .</p>
<p>The values are then converted to the destination data type:</p><ul>
<li>8-bit images: \(V \leftarrow 255 \cdot V, S \leftarrow 255 \cdot S, H \leftarrow H/2 \; \text{(to fit to 0 to 255)}\)</li>
<li>16-bit images: (currently not supported) \(V &lt;- 65535 \cdot V, S &lt;- 65535 \cdot S, H &lt;- H\)</li>
<li>32-bit images: H, S, V are left as is</li>
</ul>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a3070ca753ff41d655e87315bee03d8af" title="convert RGB/BGR to HLS (hue lightness saturation) with H range 0..180 if 8 bit image, color conversions ">cv::COLOR_BGR2HLS</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0ac3d926b985b034433c49fc84de84c85f">cv::COLOR_RGB2HLS</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a1dc9f081ce5202ade309e319414c14cd" title="backward conversions HLS to RGB/BGR with H range 0..180 if 8 bit image ">cv::COLOR_HLS2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a501d0d119ebbf50ddbbf3743f2783aca">cv::COLOR_HLS2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_lab"></a></p><h2>RGB \(\leftrightarrow\) CIE L*a*b* </h2>
<p>In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit the 0 to 1 range.</p>
<p class="formulaDsp">
\[\vecthree{X}{Y}{Z} \leftarrow \vecthreethree{0.412453}{0.357580}{0.180423}{0.212671}{0.715160}{0.072169}{0.019334}{0.119193}{0.950227} \cdot \vecthree{R}{G}{B}\]
</p>
 <p class="formulaDsp">
\[X \leftarrow X/X_n, \text{where} X_n = 0.950456\]
</p>
 <p class="formulaDsp">
\[Z \leftarrow Z/Z_n, \text{where} Z_n = 1.088754\]
</p>
 <p class="formulaDsp">
\[L \leftarrow \fork{116*Y^{1/3}-16}{for \(Y&gt;0.008856\)}{903.3*Y}{for \(Y \le 0.008856\)}\]
</p>
 <p class="formulaDsp">
\[a \leftarrow 500 (f(X)-f(Y)) + delta\]
</p>
 <p class="formulaDsp">
\[b \leftarrow 200 (f(Y)-f(Z)) + delta\]
</p>
<p> where </p><p class="formulaDsp">
\[f(t)= \fork{t^{1/3}}{for \(t&gt;0.008856\)}{7.787 t+16/116}{for \(t\leq 0.008856\)}\]
</p>
<p> and </p><p class="formulaDsp">
\[delta = \fork{128}{for 8-bit images}{0}{for floating-point images}\]
</p>
<p>This outputs \(0 \leq L \leq 100\), \(-127 \leq a \leq 127\), \(-127 \leq b \leq 127\) . The values are then converted to the destination data type:</p><ul>
<li>8-bit images: \(L \leftarrow L*255/100, \; a \leftarrow a + 128, \; b \leftarrow b + 128\)</li>
<li>16-bit images: (currently not supported)</li>
<li>32-bit images: L, a, and b are left as is</li>
</ul>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a860b72b4741c431e81340fafef5eca24" title="convert RGB/BGR to CIE Lab, color conversions ">cv::COLOR_BGR2Lab</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0afc25858d4f1127d6051d881d5f4e2b6e">cv::COLOR_RGB2Lab</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a966fd47d10ad71c4220b3ef9f1ac5774">cv::COLOR_Lab2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a50988b0e1e8369628a55cc8860dfbf69">cv::COLOR_Lab2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_rgb_luv"></a></p><h2>RGB \(\leftrightarrow\) CIE L*u*v* </h2>
<p>In case of 8-bit and 16-bit images, R, G, and B are converted to the floating-point format and scaled to fit 0 to 1 range.</p>
<p class="formulaDsp">
\[\vecthree{X}{Y}{Z} \leftarrow \vecthreethree{0.412453}{0.357580}{0.180423}{0.212671}{0.715160}{0.072169}{0.019334}{0.119193}{0.950227} \cdot \vecthree{R}{G}{B}\]
</p>
 <p class="formulaDsp">
\[L \leftarrow \fork{116*Y^{1/3} - 16}{for \(Y&gt;0.008856\)}{903.3 Y}{for \(Y\leq 0.008856\)}\]
</p>
 <p class="formulaDsp">
\[u&#39; \leftarrow 4*X/(X + 15*Y + 3 Z)\]
</p>
 <p class="formulaDsp">
\[v&#39; \leftarrow 9*Y/(X + 15*Y + 3 Z)\]
</p>
 <p class="formulaDsp">
\[u \leftarrow 13*L*(u&#39; - u_n) \quad \text{where} \quad u_n=0.19793943\]
</p>
 <p class="formulaDsp">
\[v \leftarrow 13*L*(v&#39; - v_n) \quad \text{where} \quad v_n=0.46831096\]
</p>
<p>This outputs \(0 \leq L \leq 100\), \(-134 \leq u \leq 220\), \(-140 \leq v \leq 122\) .</p>
<p>The values are then converted to the destination data type:</p><ul>
<li>8-bit images: \(L \leftarrow 255/100 L, \; u \leftarrow 255/354 (u + 134), \; v \leftarrow 255/262 (v + 140)\)</li>
<li>16-bit images: (currently not supported)</li>
<li>32-bit images: L, u, and v are left as is</li>
</ul>
<p>Note that when converting integer Luv images to RGB the intermediate X, Y and Z values are truncated to \( [0, 2] \) range to fit white point limitations. It may lead to incorrect representation of colors with odd XYZ values.</p>
<p>The above formulae for converting RGB to/from various color spaces have been taken from multiple sources on the web, primarily from the Charles Poynton site <a href="http://www.poynton.com/ColorFAQ.html">http://www.poynton.com/ColorFAQ.html</a></p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a8199112edf021b1586c75ca20a46ecd1" title="convert RGB/BGR to CIE Luv, color conversions ">cv::COLOR_BGR2Luv</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a5e11d9e294ba89668c080662a8321e45">cv::COLOR_RGB2Luv</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a514896aa2d19659f6a2eca67bb0748f1">cv::COLOR_Luv2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a8d68e3f1814d0a649731c0f56835b8c3">cv::COLOR_Luv2RGB</a></dd></dl>
<p><a class="anchor" id="color_convert_bayer"></a></p><h2>Bayer \(\rightarrow\) RGB </h2>
<p>The Bayer pattern is widely used in CCD and CMOS cameras. It enables you to get color pictures from a single plane where R,G, and B pixels (sensors of a particular component) are interleaved as follows:</p>
<div class="image">
<img src="../../bayer.png" alt="bayer.png"/>
<div class="caption">
Bayer pattern</div></div>
<p> The output RGB components of a pixel are interpolated from 1, 2, or 4 neighbors of the pixel having the same color. There are several modifications of the above pattern that can be achieved by shifting the pattern one pixel left and/or one pixel up. The two letters \(C_1\) and \(C_2\) in the conversion constants CV_Bayer \(C_1 C_2\) 2BGR and CV_Bayer \(C_1 C_2\) 2RGB indicate the particular pattern type. These are components from the second row, second and third columns, respectively. For example, the above pattern has a very popular "BG" type.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a8945844ab075687f4d4196abe1ce0db4" title="Demosaicing. ">cv::COLOR_BayerBG2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0acef801137d9696dcb622122a7ef266c6">cv::COLOR_BayerGB2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a275d4d0ff99fdf45b2b6b421a14ec831">cv::COLOR_BayerRG2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0afe3d71ad80f5f067d3d76b376cf8d951">cv::COLOR_BayerGR2BGR</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0abb38ecd5317747c872d3775196abe142">cv::COLOR_BayerBG2RGB</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0a93f007ad1b8f904f6e8c54dd8ccd4049">cv::COLOR_BayerGB2RGB</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0ade83fb9a89e974207e5fef472f28adf3">cv::COLOR_BayerRG2RGB</a>, <a class="el" href="../../d8/d01/group__imgproc__color__conversions.html#gga4e0972be5de079fed4e3a10e24ef5ef0aac8c643ccf0c9d9407bd0cb9a18520d2">cv::COLOR_BayerGR2RGB</a> </dd></dl>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:33 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
